//
//  RHLocalSettingTypeModel.m
//  RuiHeAppApp
//
//  Created by Yan Chen on 2024/4/9.
//

#import "RHLocalSettingTypeModel.h"
#import "SYChartTool.h"
#import "CBLECenterMnger.h"
#import "NetworkConfig.h"
@interface RHLocalSettingTypeModel()



@end

@implementation RHLocalSettingTypeModel

+(RHLocalSettingTypeModel*)getTypeModelWithSettingType:(LocalSettingType)type
{
    //默认kowint 低压
    NSArray *file_names = @[@"setting_ems_lv_kowint",//每个品牌,以及高低压的逆变器匹配的都不一样
                            @"setting_master_lv",//低压的M_HighSystemSet1,M_HighSystemSet2两组高压参数设置去掉
                            @"setting_pack",
                            @"setting_pcs"
                         ];
    //瑞诺 低压
    if ([CBLECenterMnger shareMnger].curPheral.brandType == DevBrandTypeRenon) {
        file_names = @[@"setting_ems_lv_renon",//每个品牌,以及高低压的逆变器匹配的都不一样
                                @"setting_master_lv",//低压的M_HighSystemSet1,M_HighSystemSet2两组高压参数设置去掉
                                @"setting_pack",
                                @"setting_pcs"
                             ];
    }
    //中瑞 低压
    if ([CBLECenterMnger shareMnger].curPheral.brandType == DevBrandTypeZRGP) {
        file_names = @[@"setting_ems_lv_zrgp",//每个品牌,以及高低压的逆变器匹配的都不一样
                                @"setting_master_lv",//低压的M_HighSystemSet1,M_HighSystemSet2两组高压参数设置去掉
                                @"setting_pack",
                                @"setting_pcs"
                             ];
    }
    
    if ([CBLECenterMnger shareMnger].curPheral.isHighVoltage) {
        //纳通高压pack模块去掉
        file_names = @[@"setting_ems_hv_kowint",//每个品牌,以及高低压的逆变器匹配的都不一样
                                @"setting_master_hv",//低压的指令没有那么多,只留一项,M_LowSystemSet(低压)去掉
                                @"setting_pack",
                                @"setting_pcs"
                             ];
        //瑞诺 高压
        if ([CBLECenterMnger shareMnger].curPheral.brandType == DevBrandTypeRenon) {
            file_names = @[@"setting_ems_hv_renon",//每个品牌,以及高低压的逆变器匹配的都不一样
                                    @"setting_master_hv",//低压的指令没有那么多,只留一项,M_LowSystemSet(低压)去掉
                                    @"setting_pack",
                                    @"setting_pcs"
                                 ];
        }
        //中瑞 高压
        if ([CBLECenterMnger shareMnger].curPheral.brandType == DevBrandTypeZRGP) {
            file_names = @[@"setting_ems_hv_zrgp",//每个品牌,以及高低压的逆变器匹配的都不一样
                                    @"setting_master_hv",//低压的指令没有那么多,只留一项,M_LowSystemSet(低压)去掉
                                    @"setting_pack",
                                    @"setting_pcs"
                                 ];
        }
    }
    //pack1-6
    NSInteger fileIndex = type;
    if(type >= 101){
        fileIndex = 2;
    }
    NSDictionary *dict = [SYChartTool readLocalJsonFileWithName:file_names[fileIndex]];
    NSLog(@"--->加载的json文件:%@",file_names[fileIndex]);
    RHLocalSettingModel *model = [RHLocalSettingModel yy_modelWithDictionary:dict];
    RHLocalSettingTypeModel *type_model = [[RHLocalSettingTypeModel alloc] init];
    type_model.settingType = type;
    type_model.dataList = model.dataList.copy;
    return type_model;
}

-(NSString*)getEndpointCode
{
    switch (self.settingType) {
        case LocalSettingType_EMS:
            return @"EMS";
            break;
        case LocalSettingType_Master:
            return @"Master";
            break;
        case LocalSettingType_Pack1:
            return @"Pack";
            break;
        case LocalSettingType_Pack2:
            return @"Pack";
            break;
        case LocalSettingType_Pack3:
            return @"Pack";
            break;
        case LocalSettingType_Pack4:
            return @"Pack";
            break;
        default: return @"";
            break;
    }
}
@end
